// A schema description of the config.json format
// json-schema.org / http://tools.ietf.org/html/draft-zyp-json-schema-03

{
  "description" : "qooxdoo Configuration Json Schema, vers. 1.3",
  "type" : "object",

  "properties" : 
  {
    "name" : 
    {
      "description" : "A name / short description for the configuration file",
      "type"  : "string" 
    },

    "include" :
    {
      "description" : "A list of libraries to include; each library is represented by a map",
      "type"  : "array",
      "items" :
      {
        "description" : "A map describing a library",
        "type"  : "object",
        "properties" : 
        {
          "path" :
          {
            "description"  : "The path to the library's Manifest.json",
            "required" : true,
            "type"   : "string"
          },
          "uri"  :
          {
            "description"   : "The URI prefix from the index.html up to the libraries top folder",
            "type"    : "string"
          }
        }
      }
    },

    "export" :
    {
      "description" : "A list of job names exported by this configuration",
      "type"  : "array",
      "items" :
      {
        "description"  : "A job name from the current config (including imported jobs)",
        "type"   : "string"
      }
    },

    "let" :
    {
      "description" : "A global map of macros; this will be included in every job",
      "type"  : "object",
      "properties" : 
      {
        "<macro_name>" :
        {
          "description" : "A macro name is an arbitrary but unique indentifier",
          //"type"  : "string|map|list"
          "type"  : "string"
        }
      }
    },

    "jobs" : 
    {
      "description" : "A map of job entries",
      "type"  : "object",
      "additionalProperties" :
      // "<job_entry>" :
      {
        "description" : "A job description; <job_entry> is an arbitrary but unique identifier.",
        "type"  : "object",
        "properties" :
        {

          "api" :
          {
            "description" : "Triggers the generation of a custom Apiviewer application.",
            "type"  : "object",
            "properties" :
            {
              "path" : 
              {
                "required" : true,
                "description"  : "Path where the Apiviewer application is to be stored, relative to the current directory.",
                "type"   : "string"
              }
            }
          },

          "cache" :
          {
            "description"  : "Define the paths to cache directories, particularly to the compile cache.",
            "type"   : "object",
            "properties" :
            {
              "compile"  :
              {
                "description" : "path to the 'main' cache, the directory where compile results are cached, relative to the current (default: './cache')",
                "type"  : "string"
              },
              "downloads" :
              {
                "description"  : "directory where to put downloads (e.g. contrib:// libraries), relative to the current (default: './cache-downloads')",
                "type"   : "string"
              }
            }
          },
          
          "clean-files" :
          {
            "description" : "Triggers clean-up of files and directories within a project and the framework, e.g. deletion of generated files, cache contents, etc.",
            "type"  : "object",
            "properties" : 
            {
              "<doc_string>" :
              {
                "description" : "arbitrary string explaining what get's cleaned",
                "type"  : "array",
                "properties" :
                [
                  {
                    "description" : "file/path to be deleted; may be relative to config file location",
                    "type"  : "string"
                  }
                ]
              }
            }
          },

          "combine-images" :
          {
            "description" : "Triggers creation of a combined image file that contains various images.",
            "type"  : "object",
            "properties" :
            {
              "images" :
              {
                "description" : "map with combine entries",
                "type"  : "object",
                "properties" :
                {
                  "<output_image>" :
                  {
                    "description" : "path of output file; may be relative to the config file location",
                    "type"  : "object",
                    "properties" :
                    {
                      "input" :
                      {
                        "description"  : "lists the input image files (file globs allowed); may be relative to config file location",
                        "required" : true,
                        "type"   : "array",
                        "properties" :
                        [ 
                          {
                            "description" : "path to an input image file",
                            "type"  : "string"
                          }
                        ],
                      },

                      "layout" :
                      {
                        "description" : "either horizontal or vertical; defines the layout of images within the combined image",
                        "enum"  : ["horizontal", "vertical"]
                      }
                    }
                  }
                }
              }
            }
          },

          "compile-options" :
          {
            "description" : "General compile options, a super-set of source and build options.",
            "type"  : "object",
            "properties" :
            {
              "file" :
              {
                "description" : "the path to the compile output file, may be relative to config file location",
                "required" : true,
                "type"  : "string"
              },
              "root" :
              {
                "description" : "relative path to the directory containing the app’s HTML",
                "required" : true,
                "type"  : "string"
              },
              "uri"  :
              {
                "description" : "the path to the output file(s), relative to the application’s index.html",
                "type"  : "string"
              },
              "gzip" :
              {
                "description" : "whether to compress output file(s)",
                "type"  : "boolean"
              },
              "optimize":
              {
                "description" : "enable the named optimizations",
                "type"  : "array",
                "items" :
                {
                  "enum"  : ["variables", "basecalls", "privates", "strings"],
                }
              },
              "resourceUri" :
              {
                "description" : "relative path from html file to root of resource tree",
                "type"  : "string"
              },
              "locales" :
              {
                "description" : "a list of locales to include (default: ['C'])",
                "type"  : "array",
                "properties" :
                [
                  {
                    "type" : "string"
                  }
                ]
              },
              "format"  :
              {
                "description" : "on/off, for simple output formatting (it adds some sensible line breaks to the output code)",
                "enum"  : ["on", "off"]
              }
            }
          },
      
          "compile" :
          {
            "description" : "Triggers generation of a source or build version of the application."
          },

          "copy-files" : 
          {
            "description" : "Triggers files/directories to be copied, usually between source and build version."
          },

          "copy-resources" :
          {
            "description" : "Triggers the copying of resources, usually between source and build version."
          },

          "environment" :
          {
            "description" : "Define global key:value pairs for the generated application."
          },

          "extend" :
          {
            "description" : "Extend the current job with other jobs. Takes an array of job names. The information of these jobs are merged into the current job description, so the current job sort of “inherits” their settings. (See the special section on 'extend' semantics)."
          },

          "include" :
          {
            "description" : "List classes to be processed in the job. Takes an array of class specifiers."
          },

          "let" :
          {
            "description" : "Define macros. Takes a map where each key defines a macro and the value its expansion."
          },

          "library" :
          {
            "description" : "Define libraries to be taken into account for this job. Takes an array of maps, each map specifying one library to consider. The most important part therein is the “manifest” specification. (See special section on Manifest files)."
          },

          "packages" :
          {
            "description" : "Define packages for the application. (See special section on packages)."
          },

          "pretty-print" :
          {
            "description" : "Triggers code beautification of source class files (in-place-editing). An empty map value triggers default formatting, but further keys can tailor the output."
          },

          "require" :
          {
            "description" : "Define prerequisite classes. Takes a map, where the keys are class names and the values lists of prerequisite classes."
          },

          "run" :
          {
            "description" : "Define a list of jobs to run in place of the current job. (See the special section on 'run' semantics)."
          },

          "shell" :
          {
            "description" : "Triggers the execution of an external command."
          },

          "slice-images" :
          {
            "description" : "Triggers cutting images into regions."
          },

          "asset-let" :
          {
            "description" : "Defines theme keys that will be replaced in #asset hints in source files. (See special section on the 'themes' key)."
          },

          "translate" :
          {
            "description" : "(Re-)generate .po files from source classes."
          }
        }
      }
    }
  }
}
